import com.mysql.jdbc.Connection;
import com.mysql.jdbc.jdbc2.optional.MysqlDataSource;
import java.sql.PreparedStatement;
import java.sql.SQLException;
//删除操作
public class DelBooks {
    public static void main(String[] args) throws SQLException {
        MysqlDataSource dataSource=new MysqlDataSource();
        dataSource.setURL("jdbc:mysql://127.0.0.1:3306/book?characterEnding=utf8&useSSL=true");
        dataSource.setUser("root");
        dataSource.setPassword("123456");
        Connection connection=(Connection) dataSource.getConnection();
        String delSql="delete from books where id=?";
        PreparedStatement statement=connection.prepareStatement(delSql);
        statement.setInt(1,1);
        int result=statement.executeUpdate();
        System.out.println("受影响的行数:"+result);
        statement.close();
        connection.close();
    }
}
